package mse.eai.esb;

import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ScheduledEventMessageComposer;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
import org.jboss.soa.esb.schedule.SchedulingException;

public class LotteryResultsMessageComposer implements
		ScheduledEventMessageComposer {
	public void initialize(ConfigTree config) throws ConfigurationException {
		System.out.println("** initialize: " + config);
	}

	public void uninitialize() {
		System.out.println("uninitialize **");
	}

	public Message composeMessage() throws SchedulingException {
		System.out.println(this.getClass().getName() + ":composeMessage()");
		
		Message myMessage = MessageFactory.getInstance().getMessage(
				MessageType.JBOSS_XML);
		// myMessage.getBody().add("Hello Scheduled World");
		// myMessage.getProperties().setProperty(StoreMessageToFile.PROPERTY_JBESB_FILENAME,
		// "ScheduledServices.log");
		
		// TODO: ir buscar dados especificos do sorteio? ou isso vai no jBPM?
		
		return myMessage;
	}

	public Message onProcessingComplete(Message message)
			throws SchedulingException {
		System.out.println("onProcessingComplete");
		return message;
	}
}
